package iface.aplicativo.integracao.dao;

import iface.aplicativo.negocio.entidade.Menu;
import iface.arquitetura.integracao.HibernateDAOAbstrato;

import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class MenuDAO extends HibernateDAOAbstrato<Menu> {

	public Collection<Menu> obterMenusRaiz() {
		Criteria criteria = novoCriteria();

		criteria.add(Restrictions.isNull("menuPai"));

		criteria.addOrder(Order.asc("nrPosicao"));

		return consultar(criteria);
	}

	public Collection<Menu> consultarTodos() {
		Criteria criteria = novoCriteria();

		criteria.addOrder(Order.asc("nrPosicao"));

		return consultar(criteria);
	}

}
